<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>借阅信息列表</title>
<head>
    <title>借阅信息列表</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <link href="../../demo.css" rel="stylesheet" type="text/css" />

    <script src="../../scripts/boot.js" type="text/javascript"></script>
</head>
<body>
 <style type="text/css">
    html, body{
        margin:0;padding:0;border:0;width:100%;height:100%;overflow:hidden;
    }    
    </style>
    <h1>借阅信息列表</h1>      

    <div style="width:100%;">
        <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
            <table style="width:100%;">
                <tr>
                    <td style="width:100%;">
                        <a class="mini-button" iconCls="icon-add" onclick="add()">新增借阅</a> 
                    </td>
                </tr>
            </table>           
        </div>
    </div>
   <div class="mini-fit" >
    <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" allowResize="flase"
        url="/borrowinfolistaction?method=queryBorrowInfo"  idField="bookid" multiSelect="true" 
        sortField="borrowtime" sortOrder="desc" 
    >
        <div property="columns">
            <!--<div type="indexcolumn"></div>        -->      
            <div type="indexcolumn" width="25" headerAlign="center" allowSort="true">序</div>    
            <div field="borrowid" width="120" headerAlign="center" align="center" allowSort="true">借阅编号</div>
      		<div field="bookid" width="120" headerAlign="center" align="center" >图书编号</div>
            <div field="bookname" width="120" headerAlign="center" align="center" >图书名称</div>      
            <div field="borrower" width="100"  headerAlign="center" align="center" >借阅人</div>
            <div field="phone" width="100"  headerAlign="center" align="center" >联系方式</div>
            <div field="borrowtime" width="100"  headerAlign="center" align="center" allowSort="true" dateFormat="yyyy-MM-dd HH:mm:ss">借阅时间</div>
             <div field="returntime" width="120" headerAlign="center" align="center" allowSort="true" dateFormat="yyyy-MM-dd HH:mm:ss">归还时间</div>
             <div field="optionbutton" width="215" headerAlign="center" align="center" renderer="onOptionButtonRenderer">操作按钮</div>                 
        </div>
    </div>
      </div>  

    <script type="text/javascript">
        mini.parse();

        var grid = mini.get("datagrid1");
        grid.load();
        //grid.sortBy("borrowtime", "desc");
		//渲染操作按钮
        function onOptionButtonRenderer(e){
        	var borrowid=e.row.borrowid;
        	var returntime=e.row.returntime;
        	var string1="<a class=\"mini-button\" iconCls=\"icon-edit\" onclick=\"reback('"+borrowid+"')\">归还</a>";
        	var string2="<a class=\"mini-button\" iconCls=\"icon-edit\" onclick=\"del('"+borrowid+"')\">删除</a>";
        	if(!returntime){
        		return string1;
        	}
        	return string2;
        }
     
       //打开新增子页
        function add() {
            
            mini.open({
                url: bootPATH + "../pages/borrowinfo/borrowinfoadd.html",
                title: "新增借阅", width: 600, height: 400,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var data = { action: "new"};
                },
                ondestroy: function (action) {

                    grid.reload();
                }
            });
        }
    //归还
    function reback(borrowid){
        $.ajax({
            url: "/borrowinfoeditaction?method=updateBorrowInfo&borrowid="+borrowid,
            type: 'post',
            data:{data:borrowid},
            cache: false,
            success: function (text) {
            	grid.reload();
            	mini.alert("归还成功");},
				error : function() {}
        });
    }
    //删除
    function del(borrowid){
    	 mini.confirm("确定删除选中记录？","提示信息",function(action){
			  if(action=="ok"){
    	 $.ajax({
             url: "/borrowinfolistaction?method=deleteBorrowInfo&borrowid="+borrowid,
             type: 'post',
             data:{data:borrowid},
             cache: false,
             success: function (text) {
             	grid.reload();},
 				error : function() {}
         });
	 	}
    	 });
  }
	</script>

</body>
</html>